package com.lgy.springboot_example.async;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Component;

import java.util.concurrent.Future;

@Component
@EnableAsync
public class AsyncManager {

    @Async
    public void todo(Runnable runnable) {
        runnable.run();
    }

    @Async
    public Future<String> todo2(Runnable runnable) {
        runnable.run();
        return new AsyncResult<String>(null);
    }
}
